package com.hnevc.myapplication01.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.hnevc.myapplication01.R;
import com.hnevc.myapplication01.bean.WeatherBean;

import java.util.List;

public class WeatherAdapter extends BaseAdapter {
    private List<WeatherBean.ResultBean.FutureBean> weatherList;
    private Context context;

    public WeatherAdapter(List weatherList, Context context) {
        this.weatherList = weatherList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return weatherList.size();
    }

    @Override
    public Object getItem(int position) {
        return weatherList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = View.inflate(context, R.layout.weather_item_layout,null);
        }
        TextView shijian = convertView.findViewById(R.id.shijian_item);
        TextView wendu = convertView.findViewById(R.id.wendu_item);


        shijian.setText(weatherList.get(position).getDate()+"");
        wendu.setText(weatherList.get(position).getTemperature()+"");

        return convertView;
    }
}

